package cn.mw.cmdb.enums;

public enum ZabbixAssetsStatusEnum {
    ABNORMAL(0, "ABNORMAL", "异常"),
    NORMAL(1, "NORMAL", "正常"),
    SHUTDOWN(2, "SHUTDOWN", "下线"),
    UNKNOWN(3, "UNKNOWN", "未监控"),
    ALERT(4, "ALERT", "警告");

    private Integer code;
    private String status;

    private String name;

    ZabbixAssetsStatusEnum(Integer code, String status, String name) {
        this.code = code;
        this.status = status;
        this.name = name;
    }

    public String getStatus() {
        return status;
    }

    public String getName() {
        return name;
    }

    public Integer getCode() {
        return code;
    }

    public static ZabbixAssetsStatusEnum getAssetsStatusEnum(String status) {
        for (ZabbixAssetsStatusEnum assetsStatusEnum : values()) {
            if (status.equals(assetsStatusEnum.getStatus())) {
                return assetsStatusEnum;
            }
        }
        return null;
    }

    public static String getAssetsStatusName(Integer code) {
        for (ZabbixAssetsStatusEnum assetsStatusEnum : values()) {
            if (code.equals(assetsStatusEnum.getCode())) {
                return assetsStatusEnum.getName();
            }
        }
        return ABNORMAL.getName();
    }

    public static int getAssetsStatusCode(String name) {
        for (ZabbixAssetsStatusEnum assetsStatusEnum : values()) {
            if (name.equals(assetsStatusEnum.getName())) {
                return assetsStatusEnum.code;
            }
        }
        return 0;
    }

    public static ZabbixAssetsStatusEnum getAssetsStatusEnumByName(String name) {
        if (name != null) {
            for (ZabbixAssetsStatusEnum assetsStatusEnum : values()) {
                if (name.equals(assetsStatusEnum.getName())) {
                    return assetsStatusEnum;
                }
            }
        }
        return null;
    }
}
